//
//  VictorLoginView.swift
//  SinaWeibo
//
//  Created by rms on 15/10/6.
//  Copyright © 2015年 rms. All rights reserved.
//

import UIKit

protocol visitorLoginViewDelegate : NSObjectProtocol{

    func visitorWillRegister()
    
    func visitorWillLogin()

}
class VictorLoginView: UIView {

    weak var visitorDelegate :visitorLoginViewDelegate?

    @IBOutlet weak var smallIcon: UIImageView!
    
    @IBOutlet weak var iconView: UIImageView!

    @IBOutlet weak var tipLabel: UILabel!
    
    
    
    @IBAction func registerAction(sender: AnyObject) {
        
        visitorDelegate?.visitorWillRegister()
        
    }
    @IBAction func loginAction(sender: AnyObject) {
        
        visitorDelegate?.visitorWillLogin()
    }
    func setUIInfo(imageName name:String,tipText:String,isHome:Bool = false){
    
        iconView.image = UIImage(named: name)
        tipLabel.text = tipText
        smallIcon.hidden = !isHome
    
        if isHome{
        
            startAnimatinon()
        }
    }
    
    func startAnimatinon(){
    
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        anim.repeatCount = MAXFLOAT
        anim.duration = 15
        anim.toValue = 2 * M_PI
        anim.removedOnCompletion = false
        smallIcon.layer.addAnimation(anim, forKey: nil)
    
    }
}
